package com.youdianda.controller.sys;

import com.youdianda.dto.PageQueryDTO;
import com.youdianda.dto.YddArticlePageDTO;
import com.youdianda.entity.YddArticle;
import com.youdianda.entity.YddUser;
import com.youdianda.result.Result;
import com.youdianda.service.YddArticleService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Auther: zhaoss
 * @Date: 2023/5/16 - 05 - 16 - 13:30
 * @Description: com.youdianda.controller.sys
 * @version: 1.0
 */
@RestController("apiArticleController")
@RequestMapping("/index")
@Slf4j
@Api("前端文章数据")
public class ArticleController {
    @Autowired
    private YddArticleService yddArticleService;

    /**
     * 热门置顶文章数据(首页)
     * @param dto
     * @return
     */
    @GetMapping("/new")
    public Result indexNew(PageQueryDTO dto){
        return yddArticleService.indexNew(dto);
    }

    /**
     * 文章列表数据
     * @param dto
     * @return
     */
    @GetMapping("/list")
    public Result list(YddArticlePageDTO dto){
        return yddArticleService.list(dto);
    }

    /**
     * 注册
     * @param yddUser
     * @return
     */
    @PostMapping("/reg")
    public Result reg(@RequestBody YddUser yddUser){
        return yddArticleService.reg(yddUser);
    }

    /**
     * 最新文章
     * @return
     */
    @GetMapping("/hot")
    public Result hot(){
        return yddArticleService.hot();
    }

    /**
     * 推荐文章
     * @return
     */
    @GetMapping("/recommend")
    public Result recommend(){
        return yddArticleService.recommend();
    }

    /**
     * 首页和全局数据
     * @return
     */
    @GetMapping("/index")
    public Result index(){
        return yddArticleService.index();
    }

    /**
     * 文章详情数据
     * @param id
     * @return
     */
    @GetMapping("/show")
    public Result show(String id){

        return yddArticleService.show(id);
    }


}
